package com.eshop.commons.utils;

public class IDCreate{

    private volatile static SnowflakeIdWorker idWorker = new SnowflakeIdWorker(1, 1);

    /**
     * 生成唯一id
     * @return 18位id
     */
    public static synchronized Long getUniqueID(){
        return idWorker.nextId();
    }

/*    public static void main(String[] args) {
        Vector<Long> vector = new Vector<>();
        for (int i = 0; i < 1000; i++) {
            new Thread(()->{
                Long t = IDCreate.getUniqueID();
                vector.add(t);
            }).start();
        }
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Set<Long> set = new HashSet<>(vector);
        System.out.println(set.size());
        System.out.println(vector.size());
        set.forEach(System.out::println);
    }*/
}
